angular.module("shop",[]).config(["$stateProvider",function($stateProvider){
	$stateProvider.state("/shop",{
		url:"/shop",
		templateUrl:"html/shop/shop.html",

//		css:"html/shop/shop_index.css",

		css:"html/shop/shop.css",

		controller:"shopController"
	})
}]).controller("shopController",function($scope,$rootScope,$http){
	if(!$rootScope.arr5){
		$scope.msg = 0;
		$scope.msg1 = 0;
	}else{
		$scope.good=$rootScope.arr5;
		$scope.jisuan=function(){
			$scope.msg = 0;
			$scope.msg1 = 0;
			for(var i=0;i<$scope.good.length;i++){
				$scope.good[i].count = $scope.good[i].number*$scope.good[i].price;
				$scope.msg=($scope.msg*1)+$scope.good[i].count;
				$scope.msg1=($scope.msg1*1)+$scope.good[i].number;
			}
		}
 		$scope.jisuan()
		console.log($scope.arr6)
		//计算函数
		$scope.add=function($index){
			$scope.good[$index].number += 1;
			$scope.good[$index].count = $scope.good[$index].number * $scope.good[$index].price;
			$scope.jisuan();
		}
		$scope.jian=function($index){
			if($scope.good[$index].number==1){
				$scope.good.splice($index,1);
				$scope.jisuan();
			}else{
				$scope.good[$index].number-=1;
				$scope.good[$index].count=$scope.good[$index].number * $scope.good[$index].price;
				$scope.jisuan();
			}
			
		}
	}
		
		
	
	
})